package org.as3search.criteria {
	/*
	 * as3search - http://code.google.com/p/as3search
	 * Copyright (c) 2009-2010 by respective authors. All rights reserved.
	 *
	 * This library is free software; you can redistribute it and/or modify it under the
	 * terms of the GNU Lesser General Public License as published by the Free Software
	 * Foundation; either version 2.1 of the License, or (at your option) any later
	 * version.
	 *
	 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
	 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
	 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
	 *
	 * You should have received a copy of the GNU Lesser General Public License along
	 * with this library; if not, write to the Free Software Foundation, Inc.,
	 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
	 */
	
	import org.flexunit.Assert;
	
	/**
	 * 
	 */
	public class RestrictionsTestCase {
		
		private var classToTestRef : org.as3search.criteria.Restrictions;
		
		public function RestrictionsTestCase() {
			
		}
		
		[Test]
		public function testAnd():void {
			Assert.assertNotNull("and() should not return null",
				Restrictions.and(new EmptyExpression("arr1"), new EmptyExpression("arr2")));
			Assert.assertTrue("and() should return a Conjunction",
				Restrictions.and(new EmptyExpression("arr1"), new EmptyExpression("arr2")) is Conjunction);
		}
		
		[Test]
		public function testBetween():void {
			Assert.assertNotNull("between() should not return null",
				Restrictions.between("id", 0, 2));
			Assert.assertTrue("between() should return a Conjunction",
				Restrictions.between('id',0,2) is Conjunction);
		}
		
		[Test]
		public function testConjunction():void {
			Assert.assertNotNull("conjunction() should not return null",
				Restrictions.conjunction());
			Assert.assertTrue("conjunction() should return a Conjunction",
				Restrictions.conjunction() is Conjunction);
		}
		
		[Test]
		public function testDisjunction():void {
			Assert.assertNotNull("disjunction() should not return null",
				Restrictions.disjunction());
			Assert.assertTrue("disjunction() should return a Disjunction",
				Restrictions.disjunction() is Disjunction);
		}
		
		[Test]
		public function testEq():void {
			Assert.assertNotNull("eq() should not return null",
				Restrictions.eq("id", 0));
			Assert.assertTrue("eq() should return an EqualityExpression",
				Restrictions.eq("id", 0) is EqualityExpression);
		}
		
		[Test]
		public function testGe():void {
			Assert.assertNotNull("ge() should not return null",
				Restrictions.ge("id", 0));
			Assert.assertTrue("ge() should return a GreaterThanOrEqualsExpression",
				Restrictions.ge("id", 0) is GreaterThanOrEqualsExpression);
		}
		
		[Test]
		public function testGt():void {
			Assert.assertNotNull("gt() should not return null",
				Restrictions.gt("id", 0));
			Assert.assertTrue("gt() should return a GreaterThanExpression",
				Restrictions.gt("id",0) is GreaterThanExpression);
		}
		
		[Test]
		public function testIsEmpty():void {
			Assert.assertNotNull("isEmpty() should not return null",
				Restrictions.isEmpty("id"));
			Assert.assertTrue("isEmpty() should return an EmptyExpression",
				Restrictions.isEmpty("id") is EmptyExpression);
		}
		
		[Test]
		public function testIsNotEmpty():void {
			Assert.assertNotNull("isNotEmpty() should not return null",
				Restrictions.isNotEmpty("id"));
			Assert.assertTrue("isNotEmpty() should return a NotEmptyExpression",
				Restrictions.isNotEmpty("id") is NotEmptyExpression);
		}
		
		[Test]
		public function testIsNotNull():void {
			Assert.assertNotNull("isNotNull() should not return null",
				Restrictions.isNotNull("id"));
			Assert.assertTrue("isNotNull() should return a NotNullExpression",
				Restrictions.isNotNull("id") is NotNullExpression);
		}
		
		[Test]
		public function testIsNull():void {
			Assert.assertNotNull("isNull() should not return null",
				Restrictions.isNull("id"));
			Assert.assertTrue("isNull() should return a NullExpression",
				Restrictions.isNull("id") is NullExpression);
		}
		
		[Test]
		public function testLe():void {
			Assert.assertNotNull("le() should not return null",
				Restrictions.le("id",1));
			Assert.assertTrue("le() should return a LessThanOrEqualsExpression",
				Restrictions.le("id",1) is LessThanOrEqualsExpression);
		}
		
		[Test]
		public function testLt():void {
			Assert.assertNotNull("lt() should not return null",
				Restrictions.lt("id",1));
			Assert.assertTrue("lt() should return a LessThanExpression",
				Restrictions.lt("id",1) is LessThanExpression);
		}
		
		[Test]
		public function testMatches():void {
			Assert.assertNotNull("matches() should not return null",
				Restrictions.matches("name", new RegExp(".*")));
			Assert.assertTrue("matches() should return a RegExpExpression",
				Restrictions.matches("name", new RegExp(".*")) is RegExpExpression);
		}
		
		[Test]
		public function testNe():void {
			Assert.assertNotNull("ne() should not return null",
				Restrictions.ne("id",0));
			Assert.assertTrue("ne() should return a NotEqualsExpression",
				Restrictions.ne("id",0) is NotEqualsExpression);
		}
		
		[Test]
		public function testNot():void {
			Assert.assertNotNull("not() should not return null",
				Restrictions.not(new EmptyExpression("id")));
			Assert.assertTrue("not() should return a NotExpression",
				Restrictions.not(new EmptyExpression("id")) is NotExpression);
		}
		
		[Test]
		public function testOr():void {
			Assert.assertNotNull("or() should not return null",
				Restrictions.or(new EmptyExpression("firstName"), new EmptyExpression("lastName")));
			Assert.assertTrue("or() should return a Disjunction",
				Restrictions.or(new EmptyExpression("firstName"), new EmptyExpression("lastName")) is Disjunction);
		}
	}
}